home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 August: Tool Chest / Dev.CD Aug 98 TC.toast / Tool Chest / Testing & Debugging / Virtual User / Virtual User Current Release / Examples / External Tool Templates / CPlus Tool Template / Request.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-06-04  |  3.9 KB  |  139 lines  |  [TEXT/MPS ]

  1. /*
  2.  *    File:        Request.h
  3.  *
  4.  *    Contains:    xxx put contents here xxx
  5.  *
  6.  *    Written by:    Rick Violet
  7.  *
  8.  *    Copyright:    © 1992 by Apple Computer, Inc., all rights reserved.
  9.  *
  10.  *    Change History (most recent first):
  11.  *
  12.  *                09/11/94    SBR        Added ExtractValueFromNthParam for Boolean
  13.  *         <2>     4/29/93    RV        Add GetError access method
  14.  *        <5+>    11/19/92    RV        
  15.  *                11/18/92    RV        xxx put comment here xxx
  16.  *
  17.  *    To Do:
  18.  */
  19.  
  20. #ifndef __Request__
  21. #define __Request__
  22.  
  23. class Request;
  24.  
  25. /*SBR Hacked this in 05/24/94*/
  26. #ifndef __PASCALSTRING__
  27. #include        "PascalString.h"
  28. #endif
  29.  
  30. #ifndef     __TYPES__
  31. #include         <Types.h>
  32. #endif
  33.  
  34. #ifndef        __STRING__
  35. #include        <String.h>
  36. #endif
  37.  
  38. #ifndef     __Object__
  39. #include         "Object.h"
  40. #endif
  41.  
  42. #ifndef     __ScriptValue__
  43. #include         "ScriptValue.h"
  44. #endif
  45.  
  46.     /*SBR Hacked this in 10/16/94 */
  47. #ifndef     __Service__
  48. #include         "Service.h"
  49. #endif
  50.  
  51. #ifndef     __THREADS__
  52. #include         "Threads.h"
  53. #endif
  54.  
  55. const unsigned long kDefaultTimeOutSeconds = 60;
  56.  
  57. //—————————————————————————————————————————————————————————————————————————————————————
  58. //    Request class -    represents the service request from the V.U. script
  59. //—————————————————————————————————————————————————————————————————————————————————————
  60. class Request : public Object
  61. {
  62. protected:        //———————————————————————
  63.     char*            fWhichService;
  64.     VUList*            fParamList;
  65.     ScriptValue*    fReturnValue;
  66.     OSErr            fErrorCode;
  67.     char*            fErrorMessage;
  68.     unsigned long    fSendResetTicks;
  69.     Boolean            fCanceled;
  70.     long            fRequestIdentifier;
  71.  
  72.         /*SBR Hacked this in 10/16/94 */
  73.     ThreadID        fThreadID;
  74.     ThreadOptions    fThreadOptions;
  75.     Service*        fService;
  76.     
  77. public:        //———————————————————————
  78.                         Request();                        
  79. virtual                    ~Request();
  80.  
  81.         OSErr            Initialize();
  82.  
  83.         Boolean            HasBeenCanceled();
  84.         /*SBR Hacked this into Request.cp 10/16/94 */
  85.         void            CancelThisRequest();
  86.         Boolean            IsACancelRequest();
  87. virtual    Boolean            IsCancelRequestForThisRequest( Request* pCancelReq );
  88.         Boolean            IsThreaded();
  89.  
  90. virtual    void            ResetTimeOutCounter( unsigned long pNewTimeOutInterval = kDefaultTimeOutSeconds );
  91.         
  92. virtual    void            SetErrorCode( OSErr tErr );
  93. virtual    void            SetErrorMessage( char* tErrText );
  94.  
  95.         char*            GetWhichService(){ return fWhichService; };
  96.  
  97.         OSErr            GetNthParam( short pIndex, ScriptValuePtr& pValue, ValueKind& pVKind );
  98.         OSErr            ExtractValueFromNthParam( short pIndex, short* pShortPtr );
  99.         OSErr            ExtractValueFromNthParam( short pIndex, long* pLongPtr );
  100.         OSErr            ExtractValueFromNthParam( short pIndex, char* pCharPtr );
  101.         
  102.         OSErr            ExtractValueFromNthParam( short pIndex, CStr255* pCStr255Ptr );
  103.         OSErr            ExtractValueFromNthParam( short pIndex, CStr63* pCStr63Ptr );
  104.         OSErr            ExtractValueFromNthParam( short pIndex, CStr32* pCStr32Ptr );
  105.         OSErr            ExtractValueFromNthParam( short pIndex, CStr31* pCStr31Ptr );
  106.  
  107.         OSErr            ExtractValueFromNthParam( short pIndex, ScriptValue** pScriptValuePtrPtr );
  108.         OSErr            ExtractValueFromNthParam( short pIndex, char** pCharPtrPtr );
  109.         OSErr            ExtractValueFromNthParam( short pIndex, Boolean* pBooleanPtr );
  110.  
  111.         short            GetParamCount();
  112. virtual    long            GetIdentifierOfRequesttoCancel(){ return -1; };
  113.         
  114.         /*SBR Hacked this in 10/16/94 */
  115.         ThreadID        GetThreadID( ){ return fThreadID; };    
  116.         void            SetThreadID( ThreadID pThreadID ){ fThreadID = pThreadID; };    
  117.         Service*        GetService( ){ return fService; };    
  118.         void            SetService( Service* pService ){ fService = pService; };    
  119.  
  120.         void            SetReturnValue( Boolean pFlag );            
  121.         void            SetReturnValue( short pNumber );            
  122.         void            SetReturnValue( long  pLongNumber );            
  123.         void            SetReturnValue( char* pString );            
  124.         void            SetReturnValue( ScriptValue* pScriptValue );    
  125.  
  126. virtual    void            SendResult(){};
  127.         OSErr            GetError(){ return fErrorCode; };
  128.         long            GetRequestIdentifier(){ return fRequestIdentifier; };
  129.  
  130. protected:    //———————————————————————
  131.  
  132.         void            SetWhichService( char* pServiceText );
  133.         void            SetParameterList( VUList* pParamList ){ fParamList = pParamList; };
  134.         void            SetRequestIdentifier( long pID ){ fRequestIdentifier = pID; };
  135.  
  136. };
  137.  
  138. #endif
  139.